<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="../back-common.jsp"%>
<%@ include file="/WEB-INF/pages/common/taglib.jsp"%>
         <script type='text/javascript' src="<ls:templateResource item='/resources/common/js/jquery.validate.js'/>" /></script>
         <link rel="stylesheet" type="text/css" media="screen" href="${contextPath}/resources/common/css/errorform.css" />
      <table class="${tableclass}" style="width: 100%">
	    <thead>
	    	<tr><th>
				    	<strong class="am-text-primary am-text-lg">权限管理</strong> /  创建菜单
	    	</th></tr>
	    </thead>
	    </table>
        <form:form  action="${contextPath}/system/menu/save" method="post" id="form1">
            <input id="menuId" name="menuId" value="${menu.menuId}" type="hidden">
            <div align="center">
            <table border="0" align="center" class="${tableclass}" id="col1">
                <thead>
                    <tr class="sortable">
                        <th colspan="2">
                            <div align="center">
                            <c:if test="${allParentMenu !=null }">
						    	<c:forEach items="${allParentMenu }" var="menu">
						    		${menu.value } &raquo; 
						    	</c:forEach>
						    </c:if>
                                	 创建<c:choose>
									    	<c:when test="${parentMenu !=null}">${parentMenu.grade +1}级</c:when>
									       		<c:otherwise>1级</c:otherwise>
									    </c:choose>菜单
                            </div>
                        </th>
                    </tr>
                </thead>
                
		<tr>
		        <td width="30%">
		          	<div align="center">名称: <font color="ff0000">*</font></div>
		       	</td>
		        <td>
		           	<input type="text" name="name" id="name" value="${menu.name}" size="30" />
		        </td>
		</tr>
		<tr>
		        <td>
		          	<div align="center">国际化标签: </div>
		       	</td>
		        <td>
		           <input type="text" name="label" id="label" value="${menu.label}"  size="30" />
		        </td>
		</tr>
		<tr>
		        <td>
		          	<div align="center">标题: <font color="ff0000">*</font></div>
		       	</td>
		        <td>
		           	<input type="text" name="title" id="title" value="${menu.title}"  size="30" />
		        </td>
		</tr>
		<c:if test="${parentMenu != null}">
		<tr>
		        <td>
		          	<div align="center">父节点: </div>
		       	</td>
		        <td>
			        <select id="parentId" name="parentId">
			         <ls:optionGroup type="select" required="true" cache="fasle" defaultDisp="-- 父节点 --" 
		                sql=" select m.menu_id, m.name from ls_menu m where m.grade = ?" param="${parentMenu.grade}" selectedValue="${parentMenu.menuId}" />
	                </select>
		        </td>
		</tr>
		</c:if>
		<tr>
		        <td>
		          	<div align="center">连接地址: </div>
		       	</td>
		        <td>
		           <input type="text" name="action" id="action" value="${menu.action}"  size="50" />
		        </td>
		</tr>
		<tr>
		        <td>
		          	<div align="center">由那个插件提供的功能: </div>
		       	</td>
		        <td>
		           <input type="text" name="providedPlugin" id="providedPlugin" value="${menu.providedPlugin}" />
		        </td>
		</tr>
		<tr>
		        <td>
		          	<div align="center">顺序: <font color="ff0000">*</font></div>
		       	</td>
		        <td>
		           	<input type="text" name="seq" id="seq" value="${menu.seq}"  size="5" maxlength="5" />
		        </td>
		</tr>
                <tr>
                    <td colspan="2">
                        <div align="center">
                            <input class="${btnclass}" type="submit" value="保存" />
                            <input class="${btnclass}" type="reset" value="重置" />
                                    <c:choose>
							        		<c:when test="${parentMenu != null }">
							        					<input class="${btnclass}" type="button" value="返回" onclick="window.location='${contextPath}/system/menu/queryChildMenu/${parentMenu.menuId}'" /> 
							        		</c:when>
							        		<c:otherwise>
							        				<input class="${btnclass}" type="button" value="返回" onclick="window.location='<ls:url address="/system/menu/query"/>'" />
							        		</c:otherwise>
							        </c:choose>
                        </div>
                    </td>
                </tr>
            </table>
           </div>
        </form:form>
        <script language="javascript">
		    $.validator.setDefaults({
		    });

    $(document).ready(function() {
    jQuery("#form1").validate({
            rules: {
            name: {
                required: true
            },
            title: "required",
            seq: {
             	required: true,
             	number: true
            }
        },
        messages: {
            name: {
                required: '<fmt:message key="simple.errors.required"/>'
            },
            title: {
                required: '<fmt:message key="simple.errors.required"/>'
            },
            seq: {
                required: '<fmt:message key="simple.errors.required"/>',
                number: '<fmt:message key="errors.number"><fmt:param value=""/></fmt:message>'
            },           
            
        }
    });
 		highlightTableRows("col1");
		//斑马条纹
     	 $("#col1 tr:nth-child(even)").addClass("even");
});
</script>

